package com.hzspace.counter;

/**
 * @Author: LiuHao
 * @Descirption:
 * @Date: 2019/6/14_15:29
 */
public class Test {

    public static void main(String[] args) {
//        Counter1 counter = new Counter1();//没加synchronized
//        Counter2 counter = new Counter2();//方法上加synchronized
//        Counter3 counter = new Counter3();//代码块加synchronized
        Counter4 counter = new Counter4();//使用原子类



        new Thread(
                () -> counter.add()
        ).start();

        new Thread(
                () -> counter.add()
        ).start();

        new Thread(
                () -> counter.add()
        ).start();
    }

}
